package com.lagou.gateway.constants;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;

public class JsonKeySet {
    private static final BiFunction<String, List<String>, Boolean> function
            = (key, list) -> key == null ? false : list.contains(key.toLowerCase());
    private static final List<String> dataKeyNames = Arrays.asList("data");
    private static final List<String> codeKeyNames = Arrays.asList("code", "statuscode", "status");
    private static final List<String> messageKeyNames = Arrays.asList("msg", "message");

    public static Boolean keyInDataKeyNames(String key) {
        return function.apply(key, dataKeyNames);
    }

    public static Boolean keyInCodeKeyNames(String key) {
        return function.apply(key,codeKeyNames);
    }

    public static Boolean keyInMessageKeyNames(String key) {
        return function.apply(key,messageKeyNames);
    }
}
